<?php declare(strict_types=1);

/**
 * @package Light Portal
 * @link https://dragomano.ru/mods/light-portal
 * @author Bugo <bugo@dragomano.ru>
 * @copyright 2019-2025 Bugo
 * @license https://spdx.org/licenses/GPL-3.0-or-later.html GPL-3.0-or-later
 *
 * @version 3.0
 */

namespace LightPortal\UI\Partials;

use Bugo\Compat\Lang;
use Bugo\Compat\Utils;
use LightPortal\Enums\ContentClass;

if (! defined('SMF'))
	die('No direct access...');

final class ContentClassSelect extends AbstractSelect
{
	protected string $template = 'preview_select';

	public function getData(): array
	{
		$data = [];
		foreach ($this->params['data'] as $key => $template) {
			$data[] = [
				'label' => sprintf($template, empty($key) ? Lang::$txt['no'] : $key),
				'value' => $key,
			];
		}

		return $data;
	}

	protected function getDefaultParams(): array
	{
		return [
			'id'       => 'content_class',
			'multiple' => false,
			'search'   => false,
			'wide'     => false,
			'hint'     => Lang::$txt['no'],
			'data'     => ContentClass::values() ?? [],
			'value'    => Utils::$context['lp_block']['content_class'] ?? '',
		];
	}
}
